/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ies.domain.model.repository.facades;

import com.ies.domain.model.Permissao;
import com.ies.domain.model.repository.util.AbstractFacade;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaQuery;
import org.jboss.logging.Logger;

/**
 *
 * @author gustavo
 */
public class PermissaoFacade extends AbstractFacade<Permissao> {

    public PermissaoFacade() {
        super(Permissao.class);
        carregaRelacionamentos = true;
    }

    @Override
    public void create(Permissao entity) {
         EntityManager entityManager = getEntityManager();
        try {
            entityManager.getTransaction().begin();
            entityManager.persist(entity);
            entityManager.getTransaction().commit();
        } catch (Exception ex) {
            if (entityManager.getTransaction().isActive()) {
                entityManager.getTransaction().rollback();
            }
        } finally {
            entityManager.close();
        }
    }

    @Override
    public void edit(Permissao entity) {
        EntityManager entityManager = getEntityManager();
        try {
            entityManager.getTransaction().begin();
            entityManager.merge(entity);
            entityManager.getTransaction().commit();
        } catch (Exception ex) {
            Logger.getMessageLogger(PermissaoFacade.class, Logger.Level.ERROR.toString());
            if (entityManager.getTransaction().isActive()) {
                entityManager.getTransaction().rollback();
            }
        } finally {
            entityManager.close();
        }
    }
    
    
    
    

    
   
   
    
    
   
   
    
    
    
    
    
}
